<template>
	<view class="greyBox padTop_20">
		<u-cell-group>
			<u-cell-item :title-style="{'color':'#202020','font-size':'32rpx',}" title="用户协议"
				@click="toAgreement"></u-cell-item>
			<u-cell-item :title-style="{'color':'#202020','font-size':'32rpx',}" title="隐私政策"
				@click="toPrivacy"></u-cell-item>
		</u-cell-group>
		<u-cell-group>
			<u-cell-item :title-style="{'color':'#202020','font-size':'32rpx',}" title="当前版本" :value="version"
				:arrow="false"></u-cell-item>
		</u-cell-group>
		<u-cell-group>
			<u-cell-item :title-style="{'color':'#202020','font-size':'32rpx',}" title="手机号" @click="toChangePhone"
				:value="phoneText" right-icon="lock-fill" :arrow="true"></u-cell-item>
			<u-cell-item :title-style="{'color':'#202020','font-size':'32rpx',}" title="修改登录密码" @click="toChangePwd"
				right-icon="lock-fill" :arrow="true"></u-cell-item>
			<u-cell-item :title-style="{'color':'#202020','font-size':'32rpx',}" title="设置支付密码" @click="toChangePayPwd"
				right-icon="lock-fill" :arrow="true"></u-cell-item>
		</u-cell-group>


		<u-cell-group class="logOut">
			<u-cell-item :title-style="{'color':'#202020','font-size':'32rpx',}" title="退出登录" :arrow="false"
				@click="logout"></u-cell-item>
		</u-cell-group>
		<u-toast ref="uToast" />
		<u-no-network></u-no-network>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phoneText: "",
				version: ""
			}
		},
		onShow() {
			this.version = this.$config.Version
			this.phoneText = this.geTel(uni.getStorageSync('userPhone')) + " 更改"
		},
		methods: {

			toAgreement() {
				uni.navigateTo({
					url: `/pages/agreements/index`
				})
			},
			toPrivacy() {
				uni.navigateTo({
					url: `/pages/privacyPolicy/index`
				})
			},
			toChangePwd() {
				uni.navigateTo({
					url: `/pages/changePwd/index`
				})
			},
			toChangePhone() {
				uni.navigateTo({
					url: `/pages/changePhone/index`
				})
			},
			toChangePayPwd() {
				uni.navigateTo({
					url: `/pages/payPassword/index`
				})
			},
			logout() {
				let that = this
				uni.showModal({
					content: "是否确认退出当前账号？",
					confirmText: "退出",
					success: function(res) {
						if (res.confirm) {
							that.$api.logout().then((res) => {
								uni.clearStorage()
								uni.redirectTo({
									url: `/pages/login/index`
								})
							})
						}
					}
				})
			}
		}
	};
</script>

<style scoped lang="scss">
	/deep/ .u-cell-box {
		margin-bottom: 20rpx;
	}

	.logOut {
		/deep/.u-cell_title {
			margin: 0 auto;
		}

		/deep/.u-cell__value {
			flex: 0
		}
	}
</style>